package FrontEnd.Tables;

import java.util.ArrayList;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import Entities.CHillEstimator;
import Entities.CIntratagesDaten;

public class HillTabelModel extends AbstractTableModel {
	Vector<String> columnNames;
	
	ArrayList<CHillEstimator> daten;
	
	public HillTabelModel(Vector<String> columnNames, ArrayList<CHillEstimator> daten){
		this.daten = daten;
		this.columnNames = columnNames;
	}
	
	@Override
	public int getColumnCount() {
		return columnNames.size();
	}

	@Override
	public int getRowCount() {
		return daten.size();
	}

	public void setDaten(ArrayList<CHillEstimator> daten){
		this.daten = daten;
		this.fireTableDataChanged();
	}
	
	
	@Override
	public Object getValueAt(int row, int col) {
			CHillEstimator hill = daten.get(row);
			switch(col) {
		    case 0: return hill.getN();
		    case 1: return hill.getRendite();
		    case 2: return hill.getHillEsti();
		    default: return null;
		    }
		
	}
	
	
	@Override
	public String getColumnName(int column) {
        switch (column) {
        case 0:return columnNames.get(0);
        case 1:return columnNames.get(1);
        case 2:return columnNames.get(2);
        default: return null;  
        }
	}
	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		//if (this.getColumnName(columnIndex).equals("Spalte 1"))
			return false;
		//return true;
	}
	
}
